#include <stdio.h>

int 
main(void) 
{
    int type, i1, i2, i3, i4, i5, j1, j2, j3, j4, j5, check;

    puts("Enter the first (single) digit:");
    scanf("%d", &type);

    puts("Enter first group of five digits:");
    scanf("%1d%1d%1d%1d%1d", &i1, &i2, &i3, &i4, &i5);

    puts("Enter second group of five digits:");
    scanf("%1d%1d%1d%1d%1d", &j1, &j2, &j3, &j4, &j5);

    check = 9 - (((((type + i2 + j1 + j3 + j5) * 3) + \
            (i1 + i3 + i5 + j2 + j4)) - 1) % 10);

    printf("Check digit: %d\n", check);

    return 0;
}
